package com.hcms.common.utils;

import java.util.HashMap;
import java.util.Map;

// 返回结果模型
public class Result extends HashMap<String, Object> {

    public static Result ok() {
        Result result = new Result();
        result.put("code", 0);
        result.put("msg", "操作成功");
        return result;
    }

    public static Result ok(Map<String, Object> map) {
        Result result = new Result();
        result.put("code", 0);
        result.put("msg", "操作成功");
        result.putAll(map);
        return result;
    }

    public static Result error() {
        return error(-1, "操作失败");
    }

    public static Result error(String msg) {
        return error(500, msg);
    }

    public static Result error(int code, String msg) {
        Result result = new Result();
        result.put("code", code);
        result.put("msg", msg);
        return result;
    }
}
